package com.example.lenovo.appstore.activity;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.lenovo.appstore.MainActivity;
import com.example.lenovo.appstore.R;
import com.example.lenovo.appstore.base.BaseActivity;
import com.example.lenovo.appstore.utils.AppContext;
import com.example.lenovo.appstore.utils.AppManager;
import com.example.lenovo.appstore.utils.StatusBarUtil;
import com.example.lenovo.appstore.view.TitleBarView;

import butterknife.Bind;
import butterknife.ButterKnife;

public class LoginActivity extends BaseActivity implements View.OnClickListener {
    @Bind(R.id.login_title)
    TitleBarView titleBarView;
    @Bind(R.id.login_username)
    EditText login_username;//用户名
    @Bind(R.id.login_password)
    EditText login_password;//密码
    @Bind(R.id.login_comfirm_button)
    TextView login_comfirm_button;//登陆
    @Bind(R.id.regist)
    TextView regist;//快速注册
    @Bind(R.id.forgetPwd)
    TextView forgetPwd;//忘记密码


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        initView();
    }

    @Override
    protected void initView() {
        login_username.setHint(AppContext.getInstance().getResources().getString(R.string.input_userid));
        login_password.setHint(AppContext.getInstance().getResources().getString(R.string.regist_inputPhone_cn));
        regist.setText(AppContext.getInstance().getResources().getString(R.string.zhuce_cn));
        forgetPwd.setText(AppContext.getInstance().getResources().getString(R.string.find_password));
        login_comfirm_button.setText(AppContext.getInstance().getResources().getString(R.string.login));
        titleBarView.setTitle(AppContext.getInstance().getResources().getString(R.string.login));
        titleBarView.showBackButton(false);
        StatusBarUtil.setStatusBarLightMode(getWindow());
//        StatusBarUtil.setMargin(AppContext.getInstance(),titleBarView);
        initListener();
    }

    @Override
    protected void initListener() {
        regist.setOnClickListener(this);
        forgetPwd.setOnClickListener(this);
        login_comfirm_button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.regist:
                Intent toRegistr=new Intent(LoginActivity.this,RegisterActivity.class);
                startActivity(toRegistr);
                break;
            case R.id.forgetPwd:
                Intent toForgetPWD=new Intent(LoginActivity.this,ForgetPWDActivity.class);
                startActivity(toForgetPWD);
                break;
            case R.id.login_comfirm_button:
                Intent login=new Intent(LoginActivity.this,MainActivity.class);
                startActivity(login);
                AppManager.getInstance().killActivity(this);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //ButterKnife.unbind(this);

    }
}
